﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GC
{
    class Program
    {
        static void Main(string[] args)
        {
            /*Sample x1 = new Sample();
            Sample x2 = new Sample();
            x1.Dispose();
            x1 = x2;
            for (int i = 0; i < 10000; i++)
            {
                Sample s = new Sample();
            }*/
            Sample y = new Sample();
            try
            {
                y.Dowork();
            }
            catch(Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            finally
            {
                y.Dispose();

            }
            using(Sample x=new Sample())
            {
                try
                {
                    x.Dowork();
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                    
                }    
               
            }

            

                //System.GC.Collect();
                Console.ReadKey();
        }
    }
}
